;;;Special function to rename *(#).bak files created by prior versions of BACKUP.LSP
;;;Renames *(#).bak files to *(#).dwg unless the *(#).dwg file already exists.
;;;
;;;	Author:	Henry C. Francis
;;;		425 N. Ashe St.
;;;		Southern Pines, NC 28387
;;;		http://paracadd.com
;;;		All rights reserved.
;;;
;;;		COPYRIGHT: 9/25/2010
;;;		   EDITED: 9/25/2010
;;;
(DEFUN C:RENAMEBAKS ()
  (IF (SETQ fileslist (dos_getfilem "Select files" "C:\\Backups\\MO1011\\800 Drawings\\810 Design Drawings\\03 Structural\\" "Drawing backup files (*.bak)|*.bak|All files (*.*)|*.*||"))
    (PROGN
      (SETQ rename-cnt 0
	    files-cnt (LENGTH fileslist)
      )
      (FOREACH n fileslist
	(SETQ nlen (STRLEN n))
	(IF (FINDFILE (STRCAT (SUBSTR n 1 (- nlen 4)) ".dwg"))
	  NIL
	  (IF
            (DOS_RENAME n (STRCAT (SUBSTR n 1 (- nlen 4)) ".dwg"))
            (SETQ rename-cnt (1+ rename-cnt))
	  )
	)
      )
    )
    (ALERT "No files were selected! (Or too many were.)")
  )
  (IF fileslist
    (ALERT (STRCAT (ITOA rename-cnt) " of " (ITOA files-cnt) " files were renamed."))
  )
  (PRINC)
)